home *** CD-ROM | disk | FTP | other *** search
- /******************************************************************/
- /* */
- /* TurboCAD for Windows */
- /* Copyright (c) 1993 - 2001 */
- /* International Microcomputer Software, Inc. */
- /* (IMSI) */
- /* All rights reserved. */
- /* */
- /******************************************************************/
-
- // SDKDemoPpg.cpp : Implementation of the CSDKDemoPropPage property page class.
-
- #include "stdafx.h"
- #include "SDKDemo.h"
- #include "SDKDemoPpg.h"
-
- #ifdef _DEBUG
- #define new DEBUG_NEW
- #undef THIS_FILE
- static char THIS_FILE[] = __FILE__;
- #endif
-
-
- IMPLEMENT_DYNCREATE(CSDKDemoPropPage, COlePropertyPage)
-
-
- /////////////////////////////////////////////////////////////////////////////
- // Message map
-
- BEGIN_MESSAGE_MAP(CSDKDemoPropPage, COlePropertyPage)
- //{{AFX_MSG_MAP(CSDKDemoPropPage)
- ON_BN_CLICKED(IDC_FILE_BROWSE, OnFileBrowse)
- ON_BN_CLICKED(IDC_LAYER_REFRESH, OnLayerRefresh)
- ON_BN_CLICKED(IDC_LAYER_SHOW_ALL, OnLayerShowAll)
- //}}AFX_MSG_MAP
- END_MESSAGE_MAP()
-
-
- /////////////////////////////////////////////////////////////////////////////
- // Initialize class factory and guid
-
- IMPLEMENT_OLECREATE_EX(CSDKDemoPropPage, "SDKDEMO.SDKDemoPropPage.1",
- 0xa63e6665, 0xc85f, 0x11d0, 0x9b, 0x3b, 0x44, 0x45, 0x53, 0x54, 0, 0)
-
-
- /////////////////////////////////////////////////////////////////////////////
- // CSDKDemoPropPage::CSDKDemoPropPageFactory::UpdateRegistry -
- // Adds or removes system registry entries for CSDKDemoPropPage
-
- BOOL CSDKDemoPropPage::CSDKDemoPropPageFactory::UpdateRegistry(BOOL bRegister)
- {
- if (bRegister)
- return AfxOleRegisterPropertyPageClass(AfxGetInstanceHandle(),
- m_clsid, IDS_SDKDEMO_PPG);
- else
- return AfxOleUnregisterClass(m_clsid, NULL);
- }
-
-
- /////////////////////////////////////////////////////////////////////////////
- // CSDKDemoPropPage::CSDKDemoPropPage - Constructor
-
- CSDKDemoPropPage::CSDKDemoPropPage() :
- COlePropertyPage(IDD, IDS_SDKDEMO_PPG_CAPTION)
- {
- //{{AFX_DATA_INIT(CSDKDemoPropPage)
- m_strFileName = _T("");
- //}}AFX_DATA_INIT
- }
-
-
- /////////////////////////////////////////////////////////////////////////////
- // CSDKDemoPropPage::DoDataExchange - Moves data between page and properties
-
- void CSDKDemoPropPage::DoDataExchange(CDataExchange* pDX)
- {
- //{{AFX_DATA_MAP(CSDKDemoPropPage)
- DDX_Control(pDX, IDC_VISIBLE_LAYERS, m_lbLayers);
- DDP_Text(pDX, IDC_FILE_NAME, m_strFileName, _T("FileName") );
- DDX_Text(pDX, IDC_FILE_NAME, m_strFileName);
- DDV_MaxChars(pDX, m_strFileName, 256);
- //}}AFX_DATA_MAP
-
- CString strLayers;
- DDP_Text(pDX, IDC_VISIBLE_LAYERS, strLayers, _T("HideLayers"));
-
- if (!pDX->m_bSaveAndValidate)
- OnLayerRefresh();
- int nTotalCount = m_lbLayers.GetCount();
- int* rgSel = new int[nTotalCount > 0 ? nTotalCount : 1];
- if (pDX->m_bSaveAndValidate)
- {
- int nSelCount = m_lbLayers.GetSelItems(nTotalCount, rgSel);
- for (int i = 0; i < nSelCount; ++i)
- {
- CString str;
- m_lbLayers.GetText(rgSel[i], str);
- if (!str.IsEmpty())
- {
- if (!strLayers.IsEmpty())
- strLayers += "\n";
- strLayers += str;
- }
- }
- }
- else
- {
- int i = 0;
- for (i = 0; i < nTotalCount; ++i)
- m_lbLayers.SetSel(i, FALSE);
- for (i = 0; ; ++i)
- {
- CString str;
- if (!AfxExtractSubString(str, strLayers, i, '\n'))
- break;
- if (!str.IsEmpty())
- {
- int nFind = m_lbLayers.FindStringExact(-1, str);
- if (nFind < 0)
- nFind = m_lbLayers.AddString(str);
- if (nFind >= 0)
- m_lbLayers.SetSel(nFind, TRUE);
- }
- }
- }
- delete [] rgSel;
- DDP_PostProcessing(pDX);
- }
-
-
- /////////////////////////////////////////////////////////////////////////////
- // CSDKDemoPropPage message handlers
-
- void CSDKDemoPropPage::OnFileBrowse()
- {
- static TCHAR BASED_CODE szFilter[] = _T("TurboCAD Drawing Files (*.tcw)|*.tcw|All Files (*.*)|*.*||");
- CFileDialog dlg(TRUE, NULL, NULL, OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT, szFilter, this);
- if (dlg.DoModal() == IDOK && !dlg.GetPathName().IsEmpty())
- {
- m_strFileName = dlg.GetPathName();
- CDataExchange dx(this, FALSE);
- CDataExchange* pDX = &dx;
- DDX_Text(pDX, IDC_FILE_NAME, m_strFileName);
- }
- }
-
- void CSDKDemoPropPage::OnLayerRefresh()
- {
- COleDispatchDriver PropDispDriver;
- ULONG nObjects;
- LPDISPATCH* ppDisp = GetObjectArray(&nObjects);
- for (ULONG i = 0; i < nObjects; i++)
- {
- DISPID dwDispID;
- LPCOLESTR lpOleStr = OLESTR("AllLayers");
- if (SUCCEEDED(ppDisp[i]->GetIDsOfNames(IID_NULL, (LPOLESTR*)&lpOleStr, 1, 0, &dwDispID)))
- {
- CString strLayers;
- PropDispDriver.AttachDispatch(ppDisp[i], FALSE);
- PropDispDriver.GetProperty(dwDispID, VT_BSTR, &strLayers);
- PropDispDriver.DetachDispatch();
- for (int j = 0; ; ++j)
- {
- CString str;
- if (!AfxExtractSubString(str, strLayers, j, '\n'))
- break;
- if (!str.IsEmpty())
- {
- int nFind = m_lbLayers.FindStringExact(-1, str);
- if (nFind < 0)
- nFind = m_lbLayers.AddString(str);
- }
- }
- }
- }
- }
-
- void CSDKDemoPropPage::OnLayerShowAll()
- {
- if (m_hWnd != NULL)
- {
- OnLayerRefresh();
- int nCount = m_lbLayers.GetCount();
- for (int i = 0; i < nCount; ++i)
- {
- m_lbLayers.SetSel(i, FALSE);
- }
- }
- SetModifiedFlag();
- }
-
-